<template>
	<view class="content">
		<view class="tixianzhi" @click="show = true">
			<view class="tixianzhi">提现至</view>
			<view class="right-weixin">
				<text v-if="!withdrawalForm.withdraw_type">选择渠道</text>
				<text v-else>{{withdrawalForm.withdraw_type == 1? '微信': withdrawalForm.withdraw_type == 2? '支付宝': '银行卡' }}</text>
			</view>
			<!-- <view v-else style="width: 150upx;">暂无通道</view> -->
			<u-select mode="single-column"  v-model="show" :list="list" value-name="withdraw_type" label-name="name" @confirm="confirm"></u-select>
		</view>

		<view class="price-detail-box">
			<view class="price-detail-tips">
				<view class="left-tips">提现金额</view>
				<view class="right-tips"
					@click="junit('/pages/prefile/my-balance/balance-histry-list/balance-histry-list')">提现记录</view>
			</view>

			<view class="input-box">
				<view class="danwei">￥</view>
				<input v-model="withdrawalForm.withdraw_money" />
				<view style="color: #FF6027; font-size: 25upx;" @click="allinMoney()">全部提现</view>
			</view>
			<view class="line"></view>
			<view class="footer-box">
				<view class="shouxufei">{{resultMoney.poundage}}</view>
				<view class="banlance">可提现余额 ￥{{resultMoney.balance}}</view>
			</view>
		</view>

		<view class="tips" style="margin-top: 30upx;">
			1.提现48小时内到账
		</view>
		<view class="tips" style="margin-top: 10upx;">
			2.单日每人最多可提现1000
		</view>
		<view class="tixian-btn" @click="withdrawalAction">提现</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				resultMoney: {

				},
				withdrawalForm: {
					withdraw_money: '',
					withdraw_type: '',
				},
				show: false,
				list: [
					// {
					// 	value: '1',
					// 	label: 'wx'
					// },
					// {
					// 	value: '2',
					// 	label: '支付宝'
					// },
					// {
					// 	value: '3',
					// 	label: '收款账号'
					// }
				],
			};
		},
		onLoad() {
			this.getWithdrawal();
		},
		methods: {
			confirm(e){
				this.$set(this.withdrawalForm, 'withdraw_type', e[0]['value']);
				console.log(this.withdrawalForm.withdraw_type);
				// this.withdrawalForm.withdraw_type = e[0]['value'];
			},
			allinMoney() {
				this.$set(this.withdrawalForm, 'withdraw_money', this.resultMoney.balance)

			},
			junit(url) {
				uni.navigateTo({
					url: url
				})
			},
			getWithdrawal() {
				this.$http.get('user.getWithdrawal').then(res => {
					this.resultMoney = res.data;
					let arr = res.data.buttom
					if(arr.length){
						arr.length.forEach(item=>{
							if(item.up==true){
								this.list.push(item)
							}
						})
					}
				})
			},
			withdrawalAction() {
				this.$http.get('user.WithdrawalAction', this.withdrawalForm).then(res => {
					uni.showToast({
						title: res.msg
					})
					this.withdrawalForm.withdraw_money = '';
					this.getWithdrawal();
				}).catch(err => {
					if(err.errMsg == '您未配置支付宝信息，请先修改个人信息中支付宝信息' || err.errMsg =='需要完善信息'){
						setTimeout(() => {
							this.$Router.push('/pages/prefile/bank-list/bank-list');
						}, 1500)
					}
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	@import './tixian.scss';
</style>
